package org.example.myleet.p721;

import org.example.myleet.Utils.Assert;

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        Solution solution = new Solution();
        //[["John", 'john00@mail.com', 'john_newyork@mail.com', 'johnsmith@mail.com'],  ["John", "johnnybravo@mail.com"], ["Mary", "mary@mail.com"]]
//        System.out.println(solution.accountsMerge(parse(new String[][]{{"John", "johnsmith@mail.com", "john00@mail.com"}, {"John", "johnnybravo@mail.com"}, {"John", "johnsmith@mail.com", "john_newyork@mail.com"}, {"Mary", "mary@mail.com"}})));

        //[["David","David0@m.co","David1@m.co","David2@m.co","David3@m.co","David4@m.co","David5@m.co"]]
        System.out.println(solution.accountsMerge(parse(new String[][]{{"David","David0@m.co","David1@m.co"},{"David","David3@m.co","David4@m.co"},{"David","David4@m.co","David5@m.co"},{"David","David2@m.co","David3@m.co"},{"David","David1@m.co","David2@m.co"}})));
    }

    private static List<List<String>> parse(String[][] input) {
        List<List<String>> accounts = new ArrayList<>(input.length);
        for (int i=0; i<input.length; i++) {
            List<String> account = new ArrayList<>(input[i].length);
            for (int j=0; j<input[i].length; j++) {
                account.add(input[i][j]);
            }
            accounts.add(account);
        }
        return accounts;
    }
}
